package com.apes.scm.rcl.parser;

import com.apes.framework.api.SpringManager;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.Date;

/**
 * 存储过程日结解析器
 *
 * @author wuq
 * @create 2019-12-05 11:43
 */
@Data
public class ProcedureTask implements Task {

    private String procedureName;

    @Override
    public void execute(Date taskDate) {
        EntityManager entityManager = SpringManager.getBean(EntityManager.class);
        Query query = entityManager.createNativeQuery("{call "+ this.procedureName +"(?)}").setParameter(1,taskDate);
        query.executeUpdate();
    }
}
